
import http from "@/utils/http";
import {CLIENT} from '@/common/const';
import * as fn from "../script/utils";


/**
 * 专属投顾列表
 * @param {Object} option
 * @param {Number} option.productId - 产品ID
 * @param {Number} option.limit - 请求条数
 * @param {Number} option.sinceId - 起始ID
 * @param {String} option.clientCentralToken -token
 * @return {Promise} Array
 */
export  function zstgList(option) {
  const url = `${CLIENT}/client/zstgList.htm`;
  const params = {
    limit: 10,
    sinceId: "",
    ...option
  };
  return http.get(url,params);
}

/**
 * 发布专属投顾
 * @param {Object} option
 * @param {Number} option.productId - 产品ID
 * @param {Number} option.content - 内容
 * @param {String} option.clientCentralToken -token
 * @return {Promise} Array
 */
export function addZstg(option) {
  const url = `${CLIENT}/client/addZstg.htm`;
  const params = {
    content: "",
    ...option
  };
  return http.post(url, params);
}

/**
 * 获取用户专属投顾当天提问次数
 * @param {Object} option
 * @param {Number} option.productId - 产品ID
 * @param {String} option.clientCentralToken -token
 * @return {Promise} Array
 */
export  function todayZsInteractionCount(option) {
  const url = `${CLIENT}/client/todayZsInteractionCount.htm`;
  const params = {
    ...option
  };
  return http.post(url, params);
}

/**
 * 股票搜索
 * @param {Object} params
 * @param {Number} params.path
 * @param {Number} params.pageSize - 请求条数
 * @param {String} params.name - 股票名称
 * @return {Promise} Array
 */
export async function getStockList(params) {
  const url = "http://app.yueniucj.com/app/clickSearchContent.htm";
  const send = {
    searchType: 1,
    limit: 10,
    ...params
  };
  const res = await fetch(`${url}?${fn.objToParamStr(send)}`);
  const {data} = await res.json();
  return data;
}


/**
 * 用户行为统计
 * @param {Object} option
 * @return {Promise} Array
 */
export function userClickUpdate(option) {
  const url = `${CLIENT}/client/insertUserBeInfoDate.htm`;
  const data = JSON.stringify(option);
  const params = {
    data: data
  };
  return http.post(url, params);
  
}